<!DOCTYPE HTML>
<html>
<head>
<title>日志列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="__UI__/css/dpl-min.css" rel="stylesheet" type="text/css" />
<link href="__UI__/css/bui-min.css" rel="stylesheet" type="text/css" />
<link href="__UI__/css/page-min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
	<div class="row">
		<form id="searchForm" class="form-horizontal span24">
			<div class="row">
				<div class="control-group span7">
					<label class="control-label">搜索类别：</label>
					<div class="controls">
						<select id="" name="mark">
							<option value="name">行为名称</option>
							<option value="title">执行用户</option>
						</select>
					</div>
				</div>
                <div class="control-group span7">
					<label class="control-label">搜索内容：</label>
					<div class="controls">
						<input type="text" class="control-text" name="search">
					</div>
				</div>
                <div class="span3 offset2">
					<button  type="button" id="btnSearch" class="button button-primary">搜索</button>
				</div>
			</div>
		</form>
	</div>
	<div class="search-grid-container">
		<div id="grid"></div>
	</div>
</div>
<script type="text/javascript" src="__UI__/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="__UI__/js/bui-min.js"></script>
<script type="text/javascript" src="__UI__/js/config-min.js"></script>
<script type="text/javascript">
	BUI.use('common/page');
	BUI.use(['common/search','bui/overlay'],function (Search,Overlay){
		var columns = [
			{title:'行为名称',dataIndex:'action_id',width:100},
			{title:'执行用户',dataIndex:'user_id',width:100},
			{title:'日志备注',dataIndex:'remark',width:200},
			{title:'执行时间',dataIndex:'create_time',width:100}
		],
		store = Search.createStore('{:U("Home/ActionLog/index",array("module"=>$module))}',{
			proxy:{
				save:{removeUrl:'{:U("Home/ActionLog/index",array("module"=>$module))}'}
			},
			autoSync:true,
			pageSize:15
		}),
		gridCfg = Search.createGridCfg(columns,{
			forceFit:true,
			tbar:{
				items:[
					{text:'<i class="icon-refresh"></i>刷新页面',btnCls:'button button-small',handler:function(){
						window.location.reload();
					}},
					{text:'<i class="icon-remove"></i>清空日志',btnCls:'button button-small',handler:delFunction}
				]
			},
			plugins:[BUI.Grid.Plugins.CheckSelection,BUI.Grid.Plugins.RowNumber] 
		});
		var  search = new Search({
			store:store,
			gridCfg:gridCfg
		}),
		grid = search.get('grid');
		function delFunction(){
			var selections = grid.getSelection();
			delItems(selections);
		}
		function delItems(items){
			var ids = [];
			BUI.each(items,function(item){
				ids.push(item.id);
			});
			if(ids.length){
				BUI.Message.Confirm('确认要删除选中的记录么？',function(){
					$.ajax({
						url:'{:U("Home/ActionLog/del",array("module"=>$module))}',
						dataType:'json',
						data:{ids : ids},
						success:function(data){
							if(data.status == 'y'){
								search.load();
							}else{
								BUI.Message.Alert('删除失败！');
							}
						}
					});
				},'question');
			}
		}
		grid.on('cellclick',function(ev){
			var sender = $(ev.domTarget);
			if(sender.hasClass('btn-del')){
				var record = ev.record;
				delItems([record]);
			}
		});
    });
</script>
</body>
</html>  